﻿package
{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.*;
	import flash.text.TextField;
	import flash.ui.*;


    public class Main extends Sprite   //主类
    {
		var loader:Loader = new Loader();
		var player:MovieClip=new MovieClip();
		var myText:TextField = new TextField();

		public function Main(){       //程序初始化
		
			
			addChild(myText);
			addChild(player);
		

			
			this.myText.text = "wasd";

			var request:URLRequest = new URLRequest("Walk.swf");
			loader.load(request);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
			/*stage.addEventListener(KeyboardEvent.KEY_DOWN,ep.keyUpHandler);*/
		}
		function completeHandler(e:Event):void {  //
			myText.text ="载入完成";
			trace(loader.content);
			var m:MovieClip=getLibMc("blog");
			addChild(m);
			var ep=new EventProc(this);
			trace(this.numChildren);
		}
		
		public function getLibMc(name:String):MovieClip{
            var classReference = (loader.contentLoaderInfo.applicationDomain.getDefinition(name) as Class);
            return ((new (classReference) as MovieClip));
        }

		
			
    }
	
}
